<% %>
<div class=page_head>
<h2><%='Post a new message'.t%></h2>
</div>
<link href="/stylesheets/swfupload.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/javascripts/swfupload.js"></script>
<script type="text/javascript" src="/javascripts/swfhandlers.js"></script>
<script >
var upload1;
window.onload = function() {
     upload1 = new SWFUpload({
         // Backend Settings
	upload_target_url: "/files/save?uni_id=<%=session.session_id%>&pid=<%=params[:project_id]%>",	// Relative to the SWF file
	//post_params: {"sessionid" : "<%=session.to_s%>"},
	// File Upload Settings
        file_size_limit : <%=@cur_user.company.plan.max_size.to_i / 1024%>,	// 100MB
        file_types : "*.*",
        file_types_description : "All Files",
        file_upload_limit : "10",
        file_queue_limit : "0",
        begin_upload_on_queue : true,
        
	// Event Handler Settings
        file_queued_handler : uploadStart,
        file_progress_handler : uploadProgress,
        file_cancelled_handler : uploadCancel,
        file_complete_handler : uploadComplete,
        queue_complete_handler : uploadQueueComplete,
        error_handler : uploadError,

        // Flash Settings
        flash_url : "/flash/swfupload.swf",	// Relative to this file
        
	// UI Settings
        ui_container_id : "flashUI1",
        degraded_container_id : "degradedUI1",

        // Debug Settings
        debug: false 
});
     upload1.addSetting("progress_target", "fsUploadProgress1");	// Add an additional setting that will later be used by the handler.

}
</script>
<%= error_messages_for :message %>
<% form_for(:message, :url => messages_path(params[:project_id])) do |f| %>
<div class="FormBlock">
    <h2><%="Title".t%>:</h2>
    <%=f.text_field :name,:id=>'msg_name',:class=>'big_font'%><br/>
    <script>
      $('msg_name').style.width = screen.width * 0.54;
    </script>
    <strong><%="Message Category".t%>:</strong>
    <span id='cat_show'>
    <%=render :partial=>'categories/cat_show',:locals=>{:cats=>@cats,:cur_cat=>'0',:label=>'msg'}%>
    </span>
    <span class="private_label"><%="Private".t%><%=f.check_box :private%></span>


<!-- attach files-->
<div class=extra>
<div id=files>
<%=render :partial=>'files/uploaded_files',:locals=>{:uni_id=>session.session_id}%>
</div>
 <span id="attach_label">
  <%=link_to image_tag("paperclip.gif",:border=>0) + " <b>Attach files to this message...</b>".t,"#",:onclick=>"Element.toggle('Attachments');Element.toggle('attach_label')"%></span>
<div id="Attachments" class="showhide" style="display: none;border:2px #fff solid;background:#fff">
<div class="content">
<span style="float:right"><%=link_to"Close".t,"#",:onclick=>"Element.toggle('Attachments');Element.toggle('attach_label')"%></span>
<table>
<tr valign="top">
<td>
  <input id=uni_id type=hidden value='<%=session.session_id%>'>
  <input id=project_id type=hidden value='<%=params[:project_id]%>'>
  <div id="flashUI1" style="display: none;">
    <div>
       <input type="button" value="<%="Browse file ... (Max".t + " " + number_to_human_size(@cur_user.company.plan.max_size) + ")"%>" onclick="upload1.browse()" style="font-weight:bold" />
       <input id="btnCancel1" type="button" value="<%="Cancel Uploads".t%>" onclick="upload1.cancelQueue();" disabled="disabled"/><br />
    </div>

   <fieldset class="flash" id="fsUploadProgress1"> <legend><%="Attached Files".t%></legend></fieldset>
   </div>
   <!--
   <div id="degradedUI1"> 
     <div> <input type="submit" value="Submit Files" /> </div>
   </div>
   -->
  </td>
  </tr>
</table>
</div>
</div>
</div>
<!-- attach files-->
  <h2><%="Message Body".t%>:</h2>
  <table><tr><td rowspan=2>
  <%=fckeditor_text"content","message"%>
  </td>
  <td id='up_ar'><!--<%=link_to image_tag("up_arrow.gif",:border=>0),"#",:onclick=>"javascript:decrease()",:title=>"Decrease the height of textarea".t%>--> </td></tr>
  <tr><td height=14px valign=bottom><!--<%=link_to image_tag("down_arrow.gif",:border=>0),"#",:onclick=>"javascript:oFCKeditor.Height = add()",:title=>"Increase the height of the textarea".t%>--> </td></tr>
  </table>

</div>



<div class=extra>
<h2><%="Nottify people of this message by Email".t%>:</h2>
<%=check_box_tag "all",'',false,{:onclick=>"togglePeople('all_user')",:id=>'all_user'}%>
  <strong><%="All of the %s" / @project.name%></strong><br/>
<%@project.users.each do |u|%>
  <%=check_box_tag "notify_id[]",u.id,false,:class=>'all_user',:onclick=>"$('all_user').checked = false"%><%=u.name%>
<%end%>
</div>
<div class="submit">
    <div id="please_wait" style="display: none">
      <%=image_tag "progress_bar.gif"%> 
    </div>
    <div id="buttons">
    <%= submit_tag "Post this message".t,:onclick=>"Element.hide('buttons');Element.show('please_wait')"%> <%="or".t%> <%=link_to "Cancel".t,"javascript:history.back()",:class=>'admin'%>
    </div>
  </div>
<% end %>

